package com.bookyourtrek.model;

import java.math.BigInteger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.bookyourtrek.util.DbConnection;

public class UserModel {

	private PreparedStatement ps = null;
	private ResultSet rs = null;
	private String sqlQuery = "";
	private Connection conn = null;

	/**
	 * function to get userid of user
	 * @param remail
	 * @return user id
	 */
	public BigInteger getUserID(String email) {
		sqlQuery = "SELECT userid FROM bookyourtrek.user"
				+ " where email = ?;";
		conn = DbConnection.getConnection();
		try {
			ps = conn.prepareStatement(sqlQuery);
			ps.setString(1, email);
			rs = ps.executeQuery();
			if (rs.next())
				return BigInteger.valueOf(rs.getLong(1));
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			
		}
		return null;
	}

}
